<template>
  <div class="left_map com_echarts" id="left_map">
  </div>
</template>

<script>
import echarts from 'echarts';
import echartsrender from '../../../assets/js/jquery.echarts';
import china from '../../../assets/echarts/map/json/china.json';
export default {
  name: 'left_map',
  data () {
    return {
        id:"left_map",
        chart: null
    }
  },
  created () {

  },
  mounted(){
      this.initMap();
  },
  methods:{
    initMap(){
        let that = this;
        // 基于准备好的dom，初始化echarts实例
        that.chart = echarts.init(document.getElementById(this.id))
        // const chart=that.chart;
        var args = {
            mapType:'china',
            geo_itemStyle:{
                normal: {
                    areaColor: '#114181',
                    borderColor: '#20BAF0',
                    borderWidth:2
                },
                emphasis: {
                    areaColor: '#2a333d'
                }
            },
            data:[
                { name: '北京', value: that.randomData() },
                { name: '天津', value: that.randomData() },
                { name: '上海', value: that.randomData() },
                { name: '重庆', value: that.randomData() },
                { name: '河北', value: that.randomData() },
                { name: '河南', value: that.randomData() },
                { name: '云南', value: that.randomData() },
                { name: '辽宁', value: that.randomData() },
                { name: '黑龙江', value: that.randomData() },
                { name: '湖南', value: that.randomData() },
                { name: '安徽', value: that.randomData() },
                { name: '山东', value: that.randomData() },
                { name: '新疆', value: that.randomData() },
                { name: '江苏', value: that.randomData() },
                { name: '浙江', value: that.randomData() },
                { name: '江西', value: that.randomData() },
                { name: '湖北', value: that.randomData() },
                { name: '广西', value: that.randomData() },
                { name: '甘肃', value: that.randomData() },
                { name: '山西', value: that.randomData() },
                { name: '内蒙古', value: that.randomData() },
                { name: '陕西', value: that.randomData() },
                { name: '吉林', value: that.randomData() },
                { name: '福建', value: that.randomData() },
                { name: '贵州', value: that.randomData() },
                { name: '广东', value: that.randomData() },
                { name: '青海', value: that.randomData() },
                { name: '西藏', value: that.randomData() },
                { name: '四川', value: that.randomData() },
                { name: '宁夏', value: that.randomData() },
                { name: '海南', value: that.randomData() },
                { name: '台湾', value: that.randomData() },
                { name: '香港', value: that.randomData() },
                { name: '澳门', value: that.randomData() }
            ]
        }
        var option = echartsrender.map(args);
        echarts.registerMap('china',china);
        that.chart.setOption(option);
    },
    randomData () {
        return Math.round(Math.random() * 100)
    }
  }
}
</script>
<style lang='scss'  rel="stylesheet/scss" scoped>
.com_echarts{
    width:100%;
    height:100%;
}
</style>
